import 'package:flutter/material.dart';
import 'package:ytbusiness/config/yt_theme.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';
import 'package:ytbusiness/widgets/widgets.dart';

//编辑发票
class EditInvoice extends StatefulWidget {
  @override
  _EditInvoiceState createState() => _EditInvoiceState();
}

class _EditInvoiceState extends State<EditInvoice> {
  TextEditingController _invoice = TextEditingController(); //发票抬头
  TextEditingController _identifyNumber = TextEditingController(); //识别号
  TextEditingController _accountNumber = TextEditingController(); //账号
  TextEditingController _locationAndPhone = TextEditingController(); //地址、电话
  TextEditingController _eMail = TextEditingController(); //邮箱
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: () {
        FocusScope.of(context).requestFocus(FocusNode());
      },
      child: Scaffold(
        appBar: customAppBar(context, title: "编辑发票"),
        body: Container(
          color: Colors.white,
          margin: EdgeInsets.only(top: setWidth(10)),
          child: ListView(
            children: [
              Column(
                children: [
                  Container(
                    color: Colors.white,
                    padding: EdgeInsets.only(
                        left: setWidth(15),
                        right: setWidth(15),
                        top: setWidth(20),
                        bottom: setWidth(20)),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          width: setWidth(100),
                          child: Text(
                            "发票抬头:",
                            style: TextStyle(
                                color: Color(0xff323232), fontSize: setSp(15)),
                          ),
                        ),
                        Expanded(
                          child: TextField(
                            controller: _invoice,
                            textAlign: TextAlign.left,
                            style: TextStyle(fontSize: setSp(16)),
                            maxLines: null,
                            textInputAction: TextInputAction.done,
                            onSubmitted: (str) {},
                            onChanged: (val) {
                              setState(() {});
                            },
                            decoration: InputDecoration(
                              hintText: "四纪星辉传媒有限公司",
                              contentPadding: EdgeInsets.only(
                                left: setWidth(15),
                              ),
                              isDense: true,
                              border: InputBorder.none,
                              focusedBorder: InputBorder.none,
                              enabledBorder: InputBorder.none,
                            ),
                          ),
                        ),
                        Container(
                          child: Text(
                            "获取发票信息",
                            style: TextStyle(
                                color: YTTheme.theme, fontSize: setSp(13)),
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(
                        left: setWidth(15), right: setWidth(15)),
                    height: setWidth(0.5),
                    color: Color(0xffF0F0F0),
                  )
                ],
              ),
              _editItem(
                  title: "纳税人识别号",
                  controller: _identifyNumber,
                  hint: "123456789998559"),
              _editItem(
                  title: "开户行及账号",
                  controller: _accountNumber,
                  hint: "工商银行  412727199584672"),
              _editItem(
                  title: "地址、电话",
                  controller: _locationAndPhone,
                  hint: "河南省郑州市高新区863软件园\n1520525468"),
              _editItem(
                  title: "电子邮箱", controller: _eMail, hint: "1944924508@qq.com"),
              Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Container(
                    margin:
                        EdgeInsets.only(top: setWidth(12), right: setWidth(15)),
                    child: Text(
                      "用于接收电子发票",
                      style: TextStyle(
                          color: Color(0xff989898), fontSize: setSp(13)),
                    ),
                  ),
                ],
              ),
              InkWell(
                onTap: () async {},
                child: Container(
                  margin: EdgeInsets.only(
                      left: setWidth(15),
                      right: setWidth(15),
                      top: setWidth(70)),
                  decoration: BoxDecoration(
                    color: YTTheme.theme,
                    borderRadius: BorderRadius.circular(setWidth(3)),
                  ),
                  alignment: Alignment.center,
                  height: setWidth(44),
                  child: Text(
                    '保存',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: setSp(18),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget _editItem(
      {String title, TextEditingController controller, String hint}) {
    return Column(
      children: [
        Container(
          color: Colors.white,
          padding: EdgeInsets.only(
              left: setWidth(15),
              right: setWidth(15),
              top: setWidth(20),
              bottom: setWidth(20)),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                width: setWidth(100),
                child: Text(
                  "$title:",
                  style:
                      TextStyle(color: Color(0xff323232), fontSize: setSp(15)),
                ),
              ),
              Expanded(
                child: TextField(
                  controller: controller,
                  textAlign: TextAlign.left,
                  style: TextStyle(fontSize: setSp(16)),
                  maxLines: null,
                  textInputAction: TextInputAction.done,
                  onSubmitted: (str) {},
                  onChanged: (val) {
                    setState(() {});
                  },
                  decoration: InputDecoration(
                    hintText: hint,
                    contentPadding: EdgeInsets.only(
                      left: setWidth(15),
                    ),
                    isDense: true,
                    border: InputBorder.none,
                    focusedBorder: InputBorder.none,
                    enabledBorder: InputBorder.none,
                  ),
                ),
              ),
            ],
          ),
        ),
        Container(
          margin: EdgeInsets.only(left: setWidth(15), right: setWidth(15)),
          height: setWidth(0.5),
          color: Color(0xffF0F0F0),
        )
      ],
    );
  }
}
